import xhr from '../request';

export type ListForPageDataItem = {
  ID: number;
  Title: string;
  TitleEdit?: string;
  IsTitleEdit?: boolean;
  Alt: number;
  CreatedAt: string | null;
  DeletedAt: string | null;
  Kind: number;
  Lat: number;
  Lng: number;
  MemberId: number;
  Panoramic: string;
  Path: string;
  Size: number;
  Status: number;
  UpdatedAt: string;
  ThumbPreview: string,
  DeleteLoading?: boolean;
  EditLoading?: boolean;
}
export type ListForPageData = {
  Data: ListForPageDataItem[];
  Page: number;
  PageSize: number;
  Total: number
}

export type MaterialDetail = {
  Alt: number
  CreatedAt: string
  DeletedAt: string | null
  ID: number
  Info: string | null
  Kind: number
  Lat: number
  Lng: number
  MemberId: number
  Panoramic: string
  Path: string
  PathPreview: string
  Size: number
  Status: number
  ThumbPreview: string
  Title: string
  UpdatedAt: string | null
}

export default {
  listForPage(params: { Page: number, PageSize: number, Keyword: string, Kind: number }) {
    return xhr.request<ListForPageData>({ method: 'get', url: '/V1/Material/ListForPage', params })
  },

  commit(data: FormData, onUploadProgress?: (e: ProgressEvent) => void) {
    return xhr.request({ method: 'post', url: '/V1/Material/Commit', data, onUploadProgress })
  },

  delete(data: { Ids: number[] }) {
    return xhr.request({ method: 'post', url: '/V1/Material/Delete', data })
  },

  edit(data: { ID: number, Title: string }) {
    return xhr.request({ method: 'post', url: '/V1/Material/Edit', data })
  },

  detail(params: { MaterialId: number }) {
    return xhr.request<MaterialDetail>({ method: 'get', url: '/V1/Material/Detail', params })
  },


};
